package com.moyq5.mvc.maker.test.bean.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.moyq5.mvc.maker.test.bean.custom.OwnerEntity;

/**
 * 资金账单
 * @author Moyq5
 * @date 2018年7月17日
 */
@Entity
@Table(name = "uc_virtual_bill")
@DynamicUpdate
public class VirtualBill extends OwnerEntity implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	/**
	 * 账单ID（主键）
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "bill_id")
	private Long billId;
	/**
	 * 资金账户
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "account_id", nullable = false)
	private VirtualAccount account;
	/**
	 * 账单日期:yyyy-MM-dd
	 */
	@Column(name = "bill_date", nullable = false, columnDefinition="date")
	private Date billDate;
	/**
	 * 日初余额（元）
	 */
    @Column(name = "amount_begin", nullable = false, precision = 10, scale = 2)	
	private BigDecimal amountBegin;
    /**
	 * 日终余额（元）
	 */
    @Column(name = "amount_end", nullable = false, precision = 10, scale = 2)	
	private BigDecimal amountEnd;
    /**
	 * 收入（元）
	 */
    @Column(name = "amount_income", nullable = false, precision = 10, scale = 2)	
	private BigDecimal amountIncome;
    /**
	 * 支出（元）
	 */
    @Column(name = "amount_expense", nullable = false, precision = 10, scale = 2)	
	private BigDecimal amountExpense;
	/**
	 * 收入笔数
	 */
    @Column(name = "count_income", nullable = false, precision = 8, scale = 0)	
	private Integer countIncome;
    /**
	 * 支出笔数
	 */
    @Column(name = "count_expense", nullable = false, precision = 8, scale = 0)	
	private Integer countExpense;
	/**
	 * 添加时间
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
	}
	public Long getBillId() {
		return billId;
	}
	public void setBillId(Long billId) {
		this.billId = billId;
	}
	public VirtualAccount getAccount() {
		return account;
	}
	public void setAccount(VirtualAccount account) {
		this.account = account;
	}
	public Date getBillDate() {
		return billDate;
	}
	public void setBillDate(Date billDate) {
		this.billDate = billDate;
	}
	public BigDecimal getAmountBegin() {
		return amountBegin;
	}
	public void setAmountBegin(BigDecimal amountBegin) {
		this.amountBegin = amountBegin;
	}
	public BigDecimal getAmountEnd() {
		return amountEnd;
	}
	public void setAmountEnd(BigDecimal amountEnd) {
		this.amountEnd = amountEnd;
	}
	public BigDecimal getAmountIncome() {
		return amountIncome;
	}
	public void setAmountIncome(BigDecimal amountIncome) {
		this.amountIncome = amountIncome;
	}
	public BigDecimal getAmountExpense() {
		return amountExpense;
	}
	public void setAmountExpense(BigDecimal amountExpense) {
		this.amountExpense = amountExpense;
	}
	public Integer getCountIncome() {
		return countIncome;
	}
	public void setCountIncome(Integer countIncome) {
		this.countIncome = countIncome;
	}
	public Integer getCountExpense() {
		return countExpense;
	}
	public void setCountExpense(Integer countExpense) {
		this.countExpense = countExpense;
	}
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
}
